﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Team33Assignment1
{
    class Chest : GameObject
    {
        Player player;
        public Chest(Model model, Vector3 pos, Player player)
            : base(model, pos)
        {
            this.player = player;
            scaleValue = 0.05f;
        }

        public void Update(GameTime gameTime)
        {
            Vector3 direction = player.position - this.position;
            double time = 0.01;
            // Calculate the distance.
            float distanceFromGoal = Vector3.Distance(player.position, this.position);

            if (distanceFromGoal < 200f)
            {
                if (this.position != player.position)
                {
                    this.position -= (direction * (float)time);
                }
            }
            else if (distanceFromGoal > 205f)
            {
                if (this.position != player.position)
                {
                    this.position += (direction * (float)time);
                }
            }
        }
    }
}
